/**
 * 
 */
package com.nh.orderAction;

import java.util.List;

import com.nh.orderEntity.UserEntity;

/**
 * 项目名称：OrderingMiddleware
 * 
 * 类名称：LoginAction
 * 
 * 类描述：
 * 
 * 创建人：李兴建
 * 
 * E-mail:lxj08193@163.com
 * 
 * 创建时间：2012-12-19 下午02:13:15
 * 
 * 修改人：李兴建
 * 
 * 修改时间：2012-12-19 下午02:13:15
 * 
 * 修改备注：
 * 
 * @version
 */
public class LoginAction extends OrderBaseAction {
	private String name;
	private String password;

	/**
	 * 登录
	 */
	public void login() {
		String json = "[{\"info\":\"failure\"}]";

		try {
			List<UserEntity> list = this.getBaseService().findByProperty("loginName", name, UserEntity.class);
			if (list.size() > 0) {
				for (UserEntity userEntity : list) {
					if (password.equals(userEntity.getPassword())) {
						json = "[{\"info\":\"success\",\"name\":\""+userEntity.getName()+"\"}]";
						break;
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		writResponse(json);
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

}
